Vue.component("searchuser", {
    data(){
      return {
        sval:"",
        view:""
      }
    },
    props:["path", "col", "pval"],
    template:`<div style="margin:20px;">
      <el-input v-model="sval" placeholder="UserID/昵称"></el-input>
      <el-button type="primary" plain @click="opendata(1)">查询</el-button>
      <pre>{{view}}</pre>
      <el-button type="primary" plain @click="changePass()">修改登录密码</el-button>
      <el-button type="primary" plain @click="changeBankPass()">修改银行密码</el-button>
    </div>`,
    methods:{
      opendata:function(){ //请求数据
        let $this = this;
        if(this.view) this.view = "";
        http.get("/ajax/" + this.path + "?V=" + this.sval).then(function(res){
            $this.view = res.data.view;
        });
      },
      changePass:function(){ //修改登录密码
        this.$prompt('请输入登录密码', '修改密码', {
          confirmButtonText: '确定',
          cancelButtonText: '取消'
        }).then(({ value }) => {
          if(!value) return;
          let $this = this;
          http.get("/ajax/changepass?V=" + this.sval + "&P=" + value).then(function(res){
            $this.$message({message: res.data.m, type: 'success'});
          });
        }).catch(() => {
                
        });
      },
      changeBankPass:function(){ //修改银行密码
        this.$prompt('请输入银行密码', '修改密码', {
          confirmButtonText: '确定',
          cancelButtonText: '取消'
        }).then(({ value }) => {
          if(!value) return;
          let $this = this;
          http.get("/ajax/changebankpass?V=" + this.sval + "&P=" + value).then(function(res){
            $this.$message({message: res.data.m, type: 'success'});
          });
        }).catch(() => {
                
        });
      }
    },
    created:function(){
      console.log("created ", this.pval, " sval ", this.sval);
      if(this.pval){
        this.sval = this.pval;
        this.opendata();
      }
    }
  });